Skip to content

Cannot import swagger file with ref in parameters #20534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
IamIpanda opened this issue Jun 1, 2025 · 1 comment · Fixed by #20535
Closed
5 tasks done

Cannot import swagger file with ref in parameters #20534

IamIpanda opened this issue Jun 1, 2025 · 1 comment · Fixed by #20535

Comments

@IamIpanda
Copy link
Contributor

IamIpanda commented Jun 1, 2025

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.4.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Import following swagger file for custom tools:

---
openapi: 3.0.3
info:
  title: Example 
  version: 1.0.0
servers:
- url: https://dify.ai
  description: Example server
paths: 
  "/auth":
    get:
      summary: performs authentication services
      operationId: auth_get
      parameters:
      - "$ref": "#/components/parameters/param1"
      responses:
        '200':
          description: Authorization Response
components:
  parameters:
    param1:
      name: response_type
      in: query
      schema:
        type: string
        enum:
        - enum1 
        - enum2
      required: true

This is a legal swagger file.

✔️ Expected Behavior

Import success

❌ Actual Behavior

can't find the parameter name because ref is not resolved.

Copy link

dosubot bot commented Jun 1, 2025

Based on the codebase, Dify’s Swagger/OpenAPI import logic is designed to resolve $ref references in request bodies, but it appears that references in the parameters section (like "$ref": "#/components/parameters/param1") may not be fully dereferenced during import. The relevant parser (ApiBasedToolSchemaParser in parser.py) processes parameters and converts them into tool parameters, but the explicit logic for resolving $ref in parameters is not as robust as for request bodies or schemas. This could explain why your referenced parameter is not being recognized during import, resulting in the error you observed "parser.py".

There are no existing issues or documentation entries addressing this specific problem.

To work around this, try inlining the parameter definition directly in the parameters array instead of using $ref. If you need to use $ref for maintainability, you may need to adjust the import logic in Dify to explicitly resolve parameter references, similar to how it handles $ref in request bodies.

If you continue to encounter issues, providing logs or more details about the import process could help pinpoint where the reference resolution is failing.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

crazywoola pushed a commit that referenced this issue Jun 2, 2025
Co-authored-by: Peter Xin <iami@Artemis.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant